#!/usr/bin/env python3  
#coding: utf-8  
import smtplib  
import string
from email.mime.text import MIMEText 
from email.header import Header 
import ConfigParser
  

config = ConfigParser.ConfigParser()
config.read("./conf/config.ini")

def send_mail(sendmsg='', title = 'python email test', receiver=''):	
	sender = config.get("mail", "sender")
	if receiver=='' :
		receiver = config.get("mail", "receiver")
	arrReceive = string.splitfields(receiver, ",") 
	smtpserver = config.get("mail", "smtpserver")
	username = config.get("mail", "username")
	password = config.get("mail", "password")
	print sender
	print receiver
	print smtpserver
	print username
	print password
	msg = MIMEText('<html><h3>'+sendmsg+'</h3></html>','html','utf-8')  
	msg['Subject'] = Header(title, 'utf-8') 
	msg['from'] = sender
	msg['to'] = receiver
	  
	smtp = smtplib.SMTP()  
	smtp.connect(smtpserver)  
	smtp.login(username, password)  
	smtp.sendmail(sender, arrReceive, msg.as_string())  
	smtp.quit()  

if __name__ == '__main__':
	send_mail("这次怎样呢？")